Skip to content

Conversation

william-stacken
Copy link
Contributor

This is a continuation of #427, I have updated the code and added tests.

Fixes #426

@saulecabrera
Copy link
Member

FYI: the failures on Windows are (unfortunately) expected at this time, I'm working on a fix for those.

@william-stacken
Copy link
Contributor Author

The test failures appear to be due to an attempt to borrow a RefCell that is already borrowed, when GC_STRESS is active.

It seems like when RArray::new() is called at line 260 it triggers a mark of the WasiConfigInner at line 97, with an attempt to borrow it. But we already borrowed it at line 258, so it fails.

    pub fn set_mapped_directory(
        rb_self: RbSelf,
        host_path: RString,
        guest_path: RString,
        dir_perms: Symbol,
        file_perms: Symbol,
    ) -> RbSelf {
    let mut inner = rb_self.inner.borrow_mut(); // We first borrow here
    if inner.mapped_directories.is_none() {
        inner.mapped_directories = Some(RArray::new().into());
    }
    // ...
}

// RArray::new() triggers a call to here, where we attempt to borrow it again
impl DataTypeFunctions for WasiConfig {
    fn mark(&self, marker: &Marker) {
        self.inner.borrow().mark(marker); // panic happens here
    }
}

I don't have much experience with magnus or the ruby garbage collection (or rust in general), so I am not sure how to resolve this problem. Do you have any siggestions? See the backtrace for more details:

Local test run with backtrace root@b573bf1132ac:/wasmtime-rb# RUST_BACKTRACE=full GC_STRESS=true bundle exec rake spec /usr/bin/ruby3.2 -I/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib:/var/lib/gems/3.2.0/gems/rspec-support-3.13.4/lib /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb Run options: include {:focus=>true}

All examples were filtered out; ignoring {:focus=>true}
.......................................................................................................................................................................F.......................................................................................................................................................................................................F....
thread '' panicked at ext/src/ruby_api/wasi_config.rs:97:20:
RefCell already mutably borrowed
stack backtrace:
0: 0xffffb1a94868 - std::backtrace_rs::backtrace::libunwind::trace::h80a834740e37061b
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/../../backtrace/src/backtrace/libunwind.rs:117:9
1: 0xffffb1a94868 - std::backtrace_rs::backtrace::trace_unsynchronized::h8db4c318f99c6571
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/../../backtrace/src/backtrace/mod.rs:66:14
2: 0xffffb1a94868 - std::sys::backtrace::_print_fmt::h7f7b542ba53a5bc6
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/sys/backtrace.rs:66:9
3: 0xffffb1a94868 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h2747bfd80d11ff7b
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/sys/backtrace.rs:39:26
4: 0xffffb153cd9c - core::fmt::rt::Argument::fmt::he9ff5cb74d153e09
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/core/src/fmt/rt.rs:173:76
5: 0xffffb153cd9c - core::fmt::write::haee122d9e6b18100
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/core/src/fmt/mod.rs:1465:25
6: 0xffffb1a913e8 - std::io::default_write_fmt::h1ba8124286647cf9
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/io/mod.rs:639:11
7: 0xffffb1a913e8 - std::io::Write::write_fmt::he0158f6169f4cd69
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/io/mod.rs:1954:13
8: 0xffffb1a946f8 - std::sys::backtrace::BacktraceLock::print::ha08130ed18fd0194
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/sys/backtrace.rs:42:9
9: 0xffffb1a95f04 - std::panicking::default_hook::{{closure}}::hba6d19cf2c555d9c
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/panicking.rs:300:27
10: 0xffffb1a95c40 - std::panicking::default_hook::hbff32ff95437400d
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/panicking.rs:327:9
11: 0xffffb1a967cc - std::panicking::rust_panic_with_hook::h28899ec3e5e03105
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/panicking.rs:833:13
12: 0xffffb1a9651c - std::panicking::begin_panic_handler::{{closure}}::h60f6be6227bda39d
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/panicking.rs:706:13
13: 0xffffb1a94d7c - std::sys::backtrace::__rust_end_short_backtrace::hcc8118117670542a
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/sys/backtrace.rs:168:18
14: 0xffffb1a961b0 - __rustc[5224e6b81cd82a8f]::rust_begin_unwind
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/panicking.rs:697:5
15: 0xffffb14d0e08 - core::panicking::panic_fmt::hb81843b96e79b076
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/core/src/panicking.rs:75:14
16: 0xffffb14d0d84 - core::cell::panic_already_mutably_borrowed::h5ff5c992c06a39d5
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/core/src/cell.rs:793:5
17: 0xffffb1ee86d4 - core::cell::RefCell::borrow::hffd3bbe09ce5e6b0
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/core/src/cell.rs:981:25
18: 0xffffb1ee86d4 - <wasmtime_rb::ruby_api::wasi_config::WasiConfig as magnus::typed_data::DataTypeFunctions>::mark::hab54a262dc158d4f
at /wasmtime-rb/ext/src/ruby_api/wasi_config.rs:97:20
19: 0xffffb1ee86d4 - magnus::typed_data::DataTypeFunctions::extern_mark::{{closure}}::h7ee168d0f853d273
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/magnus-0.7.1/src/typed_data.rs:181:41
20: 0xffffb1ee86d4 - std::panicking::catch_unwind::do_call::h16d53244f4ef2789
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/panicking.rs:589:40
21: 0xffffb1ee86d4 - std::panicking::catch_unwind::h62d0e0843d4f98da
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/panicking.rs:552:19
22: 0xffffb1ee86d4 - std::panic::catch_unwind::h5b72a3bd34e7e21f
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/panic.rs:359:14
23: 0xffffb1ee86d4 - magnus::typed_data::DataTypeFunctions::extern_mark::h7dcc631b2156956c
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/magnus-0.7.1/src/typed_data.rs:181:25
24: 0xffffb78d637c -
25: 0xffffb78d69b0 -
26: 0xffffb78d6bbc -
27: 0xffffb78d7720 - rb_wb_protected_newobj_of
28: 0xffffb20514cc - magnus::r_array::::ary_new::h3c20194210725f0b
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/magnus-0.7.1/src/r_array.rs:57:50
29: 0xffffb20514cc - magnus::r_array::RArray::new::hfd29173965326e65
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/magnus-0.7.1/src/r_array.rs:320:21
30: 0xffffb20514cc - wasmtime_rb::ruby_api::wasi_config::WasiConfig::set_mapped_directory::h622585d9ed7c6061
at /wasmtime-rb/ext/src/ruby_api/wasi_config.rs:260:45
31: 0xffffb20514cc - core::ops::function::Fn::call::hedae584cbb0687c0
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/core/src/ops/function.rs:79:5
32: 0xffffb20514cc - magnus::method::Method4::call_convert_value::hf96d1ad11d23618f
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/magnus-0.7.1/src/method.rs:695:21
33: 0xffffb20514cc - magnus::method::Method4::call_handle_error::{{closure}}::h9b2aae77014a0141
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/magnus-0.7.1/src/method.rs:705:34
34: 0xffffb20514cc - <core::panic::unwind_safe::AssertUnwindSafe as core::ops::function::FnOnce<()>>::call_once::h019e4fcb1e2fe7c6
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/core/src/panic/unwind_safe.rs:272:9
35: 0xffffb20514cc - std::panicking::catch_unwind::do_call::ha666444302c380bc
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/panicking.rs:589:40
36: 0xffffb20514cc - std::panicking::catch_unwind::h21347004d84df1ee
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/panicking.rs:552:19
37: 0xffffb20514cc - std::panic::catch_unwind::hd64db785e87ef61c
at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/panic.rs:359:14
38: 0xffffb20514cc - magnus::method::Method4::call_handle_error::hb4bcf6a0491c66d6
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/magnus-0.7.1/src/method.rs:704:31
39: 0xffffb20514cc - wasmtime_rb::ruby_api::wasi_config::init::anon::h3936548167052ceb
at /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/magnus-0.7.1/src/method.rs:909:19
40: 0xffffb7a4aaa8 -
41: 0xffffb7a4cd24 -
42: 0xffffb7a4fb24 -
43: 0xffffb7a54258 - rb_vm_exec
44: 0xffffb7a57950 -
45: 0xffffb7a4aaa8 -
46: 0xffffb7a4cd24 -
47: 0xffffb7a513b8 -
48: 0xffffb7a54258 - rb_vm_exec
49: 0xffffb7a57950 -
50: 0xffffb7a4aaa8 -
51: 0xffffb7a4cd24 -
52: 0xffffb7a513b8 -
53: 0xffffb7a54258 - rb_vm_exec
54: 0xffffb7a586c8 - rb_yield
55: 0xffffb783aaf4 -
56: 0xffffb7a4aaa8 -
57: 0xffffb7a4cd24 -
58: 0xffffb7a513b8 -
59: 0xffffb7a54258 - rb_vm_exec
60: 0xffffb7a586c8 - rb_yield
61: 0xffffb783aaf4 -
62: 0xffffb7a4aaa8 -
63: 0xffffb7a4cd24 -
64: 0xffffb7a513b8 -
65: 0xffffb7a54258 - rb_vm_exec
66: 0xffffb7a586c8 - rb_yield
67: 0xffffb783aaf4 -
68: 0xffffb7a4aaa8 -
69: 0xffffb7a4cd24 -
70: 0xffffb7a513b8 -
71: 0xffffb7a54258 - rb_vm_exec
72: 0xffffb7a586c8 - rb_yield
73: 0xffffb783aaf4 -
74: 0xffffb7a4aaa8 -
75: 0xffffb7a4cd24 -
76: 0xffffb7a513b8 -
77: 0xffffb7a54258 - rb_vm_exec
78: 0xffffb78b1d58 -
79: 0xffffb78b63b0 - ruby_run_node
80: 0xaaaab7760b30 -
81: 0xffffb74884c4 -
82: 0xffffb7488598 - __libc_start_main
83: 0xaaaab7760bb0 - _start
84: 0x0 -
/wasmtime-rb/spec/unit/wasi_spec.rb:245: [BUG] RefCell already mutably borrowed
ruby 3.2.3 (2024-01-18 revision 52bb2ac0a6) [aarch64-linux-gnu]

-- Control frame information -----------------------------------------------
c:0044 p:---- s:0223 e:000222 CFUNC :set_mapped_directory
c:0043 p:0053 s:0215 e:000214 BLOCK /wasmtime-rb/spec/unit/wasi_spec.rb:245 [FINISH]
c:0042 p:---- s:0211 e:000210 CFUNC :instance_exec
c:0041 p:0022 s:0206 e:000205 BLOCK /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example.rb:263
c:0040 p:0002 s:0201 e:000200 BLOCK /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example.rb:511
c:0039 p:0002 s:0198 e:000197 BLOCK /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example.rb:468
c:0038 p:0002 s:0195 e:000194 BLOCK /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/hooks.rb:486
c:0037 p:0002 s:0192 e:000191 BLOCK /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/hooks.rb:626
c:0036 p:0018 s:0189 e:000188 METHOD /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example.rb:352
c:0035 p:0004 s:0183 e:000182 BLOCK /wasmtime-rb/spec/spec_helper.rb:101
c:0034 p:0015 s:0180 e:000179 METHOD /wasmtime-rb/spec/spec_helper.rb:56
c:0033 p:0004 s:0175 e:000174 BLOCK /wasmtime-rb/spec/spec_helper.rb:101 [FINISH]
c:0032 p:---- s:0171 e:000170 CFUNC :instance_exec
c:0031 p:0013 s:0166 e:000165 METHOD /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example.rb:457
c:0030 p:0010 s:0160 e:000159 METHOD /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/hooks.rb:390
c:0029 p:0009 s:0154 e:000153 BLOCK /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/hooks.rb:628
c:0028 p:0018 s:0151 e:000150 METHOD /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example.rb:352
c:0027 p:0037 s:0145 E:002178 METHOD /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/hooks.rb:629
c:0026 p:0104 s:0138 E:001f28 METHOD /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/hooks.rb:486
c:0025 p:0018 s:0131 E:0000c8 METHOD /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example.rb:468
c:0024 p:0019 s:0126 E:001cb8 METHOD /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example.rb:511
c:0023 p:0076 s:0121 E:000ac8 METHOD /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example.rb:259
c:0022 p:0037 s:0114 e:000113 BLOCK /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example_group.rb:653 [FINISH]
c:0021 p:---- s:0108 e:000107 CFUNC :map
c:0020 p:0011 s:0104 e:000103 METHOD /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example_group.rb:649
c:0019 p:0052 s:0099 e:000098 METHOD /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example_group.rb:614
c:0018 p:0006 s:0090 e:000089 BLOCK /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example_group.rb:615 [FINISH]
c:0017 p:---- s:0086 e:000085 CFUNC :map
c:0016 p:0065 s:0082 e:000081 METHOD /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example_group.rb:615
c:0015 p:0006 s:0073 e:000072 BLOCK /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example_group.rb:615 [FINISH]
c:0014 p:---- s:0069 e:000068 CFUNC :map
c:0013 p:0065 s:0065 e:000064 METHOD /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example_group.rb:615
c:0012 p:0007 s:0056 e:000055 BLOCK /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/runner.rb:121 [FINISH]
c:0011 p:---- s:0052 e:000051 CFUNC :map
c:0010 p:0030 s:0048 e:000047 BLOCK /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/runner.rb:121
c:0009 p:0026 s:0045 e:000044 METHOD /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/configuration.rb:2097
c:0008 p:0007 s:0041 e:000040 BLOCK /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/runner.rb:116
c:0007 p:0009 s:0037 e:000036 METHOD /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/reporter.rb:74
c:0006 p:0019 s:0032 e:000031 METHOD /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/runner.rb:115
c:0005 p:0035 s:0025 e:000024 METHOD /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/runner.rb:89
c:0004 p:0058 s:0019 e:000018 METHOD /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/runner.rb:71
c:0003 p:0013 s:0011 e:000010 METHOD /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/runner.rb:45
c:0002 p:0010 s:0006 e:000005 EVAL /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/exe/rspec:4 [FINISH]
c:0001 p:0000 s:0003 E:001820 DUMMY [FINISH]

-- Ruby level backtrace information ----------------------------------------
/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/exe/rspec:4:in <main>' /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/runner.rb:45:in invoke'
/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/runner.rb:71:in run' /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/runner.rb:89:in run'
/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/runner.rb:115:in run_specs' /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/reporter.rb:74:in report'
/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/runner.rb:116:in block in run_specs' /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/configuration.rb:2097:in with_suite_hooks'
/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/runner.rb:121:in block (2 levels) in run_specs' /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/runner.rb:121:in map'
/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/runner.rb:121:in block (3 levels) in run_specs' /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example_group.rb:615:in run'
/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example_group.rb:615:in map' /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example_group.rb:615:in block in run'
/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example_group.rb:615:in run' /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example_group.rb:615:in map'
/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example_group.rb:615:in block in run' /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example_group.rb:614:in run'
/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example_group.rb:649:in run_examples' /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example_group.rb:649:in map'
/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example_group.rb:653:in block in run_examples' /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example.rb:259:in run'
/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example.rb:511:in with_around_and_singleton_context_hooks' /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example.rb:468:in with_around_example_hooks'
/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/hooks.rb:486:in run' /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/hooks.rb:629:in run_around_example_hooks_for'
/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example.rb:352:in call' /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/hooks.rb:628:in block (2 levels) in run_around_example_hooks_for'
/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/hooks.rb:390:in execute_with' /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example.rb:457:in instance_exec'
/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example.rb:457:in instance_exec' /wasmtime-rb/spec/spec_helper.rb:101:in block (2 levels) in <top (required)>'
/wasmtime-rb/spec/spec_helper.rb:56:in with_gc_stress' /wasmtime-rb/spec/spec_helper.rb:101:in block (3 levels) in <top (required)>'
/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example.rb:352:in call' /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/hooks.rb:626:in block in run_around_example_hooks_for'
/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/hooks.rb:486:in block in run' /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example.rb:468:in block in with_around_example_hooks'
/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example.rb:511:in block in with_around_and_singleton_context_hooks' /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example.rb:263:in block in run'
/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib/rspec/core/example.rb:263:in instance_exec' /wasmtime-rb/spec/unit/wasi_spec.rb:245:in block (3 levels) in module:Wasmtime'
/wasmtime-rb/spec/unit/wasi_spec.rb:245:in `set_mapped_directory'

-- C level backtrace information -------------------------------------------
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a66e00) [0xffffb7a66e00]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb78aabe0) [0xffffb78aabe0]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(rb_bug+0x88) [0xffffb783271c]
/wasmtime-rb/lib/wasmtime/wasmtime_rb.so(0xffffb1a2ee4c) [0xffffb1a2ee4c]
/wasmtime-rb/lib/wasmtime/wasmtime_rb.so({closure#0}) src/error.rs:565
/wasmtime-rb/lib/wasmtime/wasmtime_rb.so(bug) src/error.rs:565
/wasmtime-rb/lib/wasmtime/wasmtime_rb.so(bug_from_panic+0x70) [0xffffb1a2ecbc] src/error.rs:559
/wasmtime-rb/lib/wasmtime/wasmtime_rb.so(extern_mark<wasmtime_rb::ruby_api::wasi_config::WasiConfig>+0x148) [0xffffb1ee8734] /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/magnus-0.7.1/src/typed_data.rs:182
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb78d637c) [0xffffb78d637c]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb78d69b0) [0xffffb78d69b0]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb78d6bbc) [0xffffb78d6bbc]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(rb_wb_protected_newobj_of+0x100) [0xffffb78d7720]
/wasmtime-rb/lib/wasmtime/wasmtime_rb.so(0xffffb20514cc) [0xffffb20514cc]
/wasmtime-rb/lib/wasmtime/wasmtime_rb.so(call<fn(magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::r_string::RString, magnus::r_string::RString, magnus::symbol::Symbol, magnus::symbol::Symbol) -> magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, (magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::r_string::RString, magnus::r_string::RString, magnus::symbol::Symbol, magnus::symbol::Symbol)>) /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/core/src/ops/function.rs:79
/wasmtime-rb/lib/wasmtime/wasmtime_rb.so(call_convert_value<fn(magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::r_string::RString, magnus::r_string::RString, magnus::symbol::Symbol, magnus::symbol::Symbol) -> magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::r_string::RString, magnus::r_string::RString, magnus::symbol::Symbol, magnus::symbol::Symbol, magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>>) /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/magnus-0.7.1/src/method.rs:695
/wasmtime-rb/lib/wasmtime/wasmtime_rb.so({closure#0}<fn(magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::r_string::RString, magnus::r_string::RString, magnus::symbol::Symbol, magnus::symbol::Symbol) -> magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::r_string::RString, magnus::r_string::RString, magnus::symbol::Symbol, magnus::symbol::Symbol, magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>>) /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/magnus-0.7.1/src/method.rs:705
/wasmtime-rb/lib/wasmtime/wasmtime_rb.so(call_once<core::result::Result<magnus::value::Value, magnus::error::Error>, magnus::method::Method4::call_handle_error::{closure_env#0}<fn(magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::r_string::RString, magnus::r_string::RString, magnus::symbol::Symbol, magnus::symbol::Symbol) -> magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::r_string::RString, magnus::r_string::RString, magnus::symbol::Symbol, magnus::symbol::Symbol, magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>>>) /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/core/src/panic/unwind_safe.rs:272
/wasmtime-rb/lib/wasmtime/wasmtime_rb.so(do_call<core::panic::unwind_safe::AssertUnwindSafe<magnus::method::Method4::call_handle_error::{closure_env#0}<fn(magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::r_string::RString, magnus::r_string::RString, magnus::symbol::Symbol, magnus::symbol::Symbol) -> magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::r_string::RString, magnus::r_string::RString, magnus::symbol::Symbol, magnus::symbol::Symbol, magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>>>, core::result::Result<magnus::value::Value, magnus::error::Error>>) /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/panicking.rs:589
/wasmtime-rb/lib/wasmtime/wasmtime_rb.so(catch_unwind<core::result::Result<magnus::value::Value, magnus::error::Error>, core::panic::unwind_safe::AssertUnwindSafe<magnus::method::Method4::call_handle_error::{closure_env#0}<fn(magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::r_string::RString, magnus::r_string::RString, magnus::symbol::Symbol, magnus::symbol::Symbol) -> magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::r_string::RString, magnus::r_string::RString, magnus::symbol::Symbol, magnus::symbol::Symbol, magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>>>>) /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/panicking.rs:552
/wasmtime-rb/lib/wasmtime/wasmtime_rb.so(catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<magnus::method::Method4::call_handle_error::{closure_env#0}<fn(magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::r_string::RString, magnus::r_string::RString, magnus::symbol::Symbol, magnus::symbol::Symbol) -> magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::r_string::RString, magnus::r_string::RString, magnus::symbol::Symbol, magnus::symbol::Symbol, magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>>>, core::result::Result<magnus::value::Value, magnus::error::Error>>) /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/panic.rs:359
/wasmtime-rb/lib/wasmtime/wasmtime_rb.so(call_handle_error<fn(magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::r_string::RString, magnus::r_string::RString, magnus::symbol::Symbol, magnus::symbol::Symbol) -> magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>, magnus::r_string::RString, magnus::r_string::RString, magnus::symbol::Symbol, magnus::symbol::Symbol, magnus::typed_data::Obj<wasmtime_rb::ruby_api::wasi_config::WasiConfig>>) /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/magnus-0.7.1/src/method.rs:704
/wasmtime-rb/lib/wasmtime/wasmtime_rb.so(anon) /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/magnus-0.7.1/src/method.rs:909
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a4aaa8) [0xffffb7a4aaa8]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a4cd24) [0xffffb7a4cd24]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a4fb24) [0xffffb7a4fb24]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(rb_vm_exec+0x1e8) [0xffffb7a54258]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a57950) [0xffffb7a57950]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a4aaa8) [0xffffb7a4aaa8]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a4cd24) [0xffffb7a4cd24]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a513b8) [0xffffb7a513b8]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(rb_vm_exec+0x1e8) [0xffffb7a54258]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a57950) [0xffffb7a57950]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a4aaa8) [0xffffb7a4aaa8]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a4cd24) [0xffffb7a4cd24]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a513b8) [0xffffb7a513b8]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(rb_vm_exec+0x1e8) [0xffffb7a54258]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(rb_yield+0x84) [0xffffb7a586c8]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb783aaf4) [0xffffb783aaf4]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a4aaa8) [0xffffb7a4aaa8]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a4cd24) [0xffffb7a4cd24]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a513b8) [0xffffb7a513b8]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(rb_vm_exec+0x1e8) [0xffffb7a54258]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(rb_yield+0x84) [0xffffb7a586c8]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb783aaf4) [0xffffb783aaf4]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a4aaa8) [0xffffb7a4aaa8]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a4cd24) [0xffffb7a4cd24]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a513b8) [0xffffb7a513b8]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(rb_vm_exec+0x1e8) [0xffffb7a54258]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(rb_yield+0x84) [0xffffb7a586c8]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb783aaf4) [0xffffb783aaf4]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a4aaa8) [0xffffb7a4aaa8]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a4cd24) [0xffffb7a4cd24]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a513b8) [0xffffb7a513b8]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(rb_vm_exec+0x1e8) [0xffffb7a54258]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(rb_yield+0x84) [0xffffb7a586c8]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb783aaf4) [0xffffb783aaf4]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a4aaa8) [0xffffb7a4aaa8]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a4cd24) [0xffffb7a4cd24]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb7a513b8) [0xffffb7a513b8]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(rb_vm_exec+0x1e8) [0xffffb7a54258]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(0xffffb78b1d58) [0xffffb78b1d58]
/lib/aarch64-linux-gnu/libruby-3.2.so.3.2(ruby_run_node+0xc0) [0xffffb78b63b0]
/usr/bin/ruby3.2(0xaaaab7760b30) [0xaaaab7760b30]
/lib/aarch64-linux-gnu/libc.so.6(0xffffb74884c4) [0xffffb74884c4]
/lib/aarch64-linux-gnu/libc.so.6(__libc_start_main+0x98) [0xffffb7488598]
/usr/bin/ruby3.2(_start+0x30) [0xaaaab7760bb0]

-- Other runtime information -----------------------------------------------

  • Process memory map:

aaaab7760000-aaaab7761000 r-xp 00000000 00:3e 2005802 /usr/bin/ruby3.2
aaaab777f000-aaaab7780000 r--p 0000f000 00:3e 2005802 /usr/bin/ruby3.2
aaaab7780000-aaaab7781000 rw-p 00010000 00:3e 2005802 /usr/bin/ruby3.2
aaaadb463000-aaaade4bf000 rw-p 00000000 00:00 0 [heap]
fffe40000000-fffe40021000 rw-p 00000000 00:00 0
fffe40021000-fffe44000000 ---p 00000000 00:00 0
fffe48000000-fffe48021000 rw-p 00000000 00:00 0
fffe48021000-fffe4c000000 ---p 00000000 00:00 0
fffe50000000-fffe50021000 rw-p 00000000 00:00 0
fffe50021000-fffe54000000 ---p 00000000 00:00 0
fffe54000000-fffe54021000 rw-p 00000000 00:00 0
fffe54021000-fffe58000000 ---p 00000000 00:00 0
fffe5c000000-fffe5c021000 rw-p 00000000 00:00 0
fffe5c021000-fffe60000000 ---p 00000000 00:00 0
fffe60000000-fffe60021000 rw-p 00000000 00:00 0
fffe60021000-fffe64000000 ---p 00000000 00:00 0
ffff47000000-ffff577bb000 r--s 00000000 00:2b 6393 /wasmtime-rb/lib/wasmtime/wasmtime_rb.so
ffff57800000-ffff67fbb000 r--p 00000000 00:2b 6393 /wasmtime-rb/lib/wasmtime/wasmtime_rb.so
ffff68000000-ffff68021000 rw-p 00000000 00:00 0
ffff68021000-ffff6c000000 ---p 00000000 00:00 0
ffff70000000-ffff70021000 rw-p 00000000 00:00 0
ffff70021000-ffff74000000 ---p 00000000 00:00 0
ffff74000000-ffff74021000 rw-p 00000000 00:00 0
ffff74021000-ffff78000000 ---p 00000000 00:00 0
ffff7c000000-ffff7c315000 rw-p 00000000 00:00 0
ffff7c315000-ffff80000000 ---p 00000000 00:00 0
ffff80000000-ffff802ad000 rw-p 00000000 00:00 0
ffff802ad000-ffff84000000 ---p 00000000 00:00 0
ffff88000000-ffff882af000 rw-p 00000000 00:00 0
ffff882af000-ffff8c000000 ---p 00000000 00:00 0
ffff90000000-ffff9033d000 rw-p 00000000 00:00 0
ffff9033d000-ffff94000000 ---p 00000000 00:00 0
ffff94000000-ffff942e7000 rw-p 00000000 00:00 0
ffff942e7000-ffff98000000 ---p 00000000 00:00 0
ffff9c000000-ffff9c2d3000 rw-p 00000000 00:00 0
ffff9c2d3000-ffffa0000000 ---p 00000000 00:00 0
ffffa4000000-ffffa4274000 rw-p 00000000 00:00 0
ffffa4274000-ffffa8000000 ---p 00000000 00:00 0
ffffa8400000-ffffa87c2000 r--s 00000000 00:3e 1858834 /usr/lib/aarch64-linux-gnu/libruby-3.2.so.3.2.3
ffffa8800000-ffffa8bc2000 r--p 00000000 00:3e 1858834 /usr/lib/aarch64-linux-gnu/libruby-3.2.so.3.2.3
ffffa8c00000-ffffa8c10000 ---p 00000000 00:00 0
ffffa8c10000-ffffa8e10000 rw-p 00000000 00:00 0
ffffa9000000-ffffa9010000 ---p 00000000 00:00 0
ffffa9010000-ffffa9210000 rw-p 00000000 00:00 0
ffffa9400000-ffffa9410000 ---p 00000000 00:00 0
ffffa9410000-ffffa9610000 rw-p 00000000 00:00 0
ffffa9800000-ffffa9810000 ---p 00000000 00:00 0
ffffa9810000-ffffa9a10000 rw-p 00000000 00:00 0
ffffa9c00000-ffffa9c10000 ---p 00000000 00:00 0
ffffa9c10000-ffffa9e10000 rw-p 00000000 00:00 0
ffffaa000000-ffffaa010000 ---p 00000000 00:00 0
ffffaa010000-ffffaa210000 rw-p 00000000 00:00 0
ffffaa400000-ffffaa410000 ---p 00000000 00:00 0
ffffaa410000-ffffaa610000 rw-p 00000000 00:00 0
ffffaa800000-ffffaa810000 ---p 00000000 00:00 0
ffffaa810000-ffffaaa10000 rw-p 00000000 00:00 0
ffffaac00000-ffffaac10000 ---p 00000000 00:00 0
ffffaac10000-ffffaae10000 rw-p 00000000 00:00 0
ffffab000000-ffffab010000 ---p 00000000 00:00 0
ffffab010000-ffffab210000 rw-p 00000000 00:00 0
ffffab400000-ffffab410000 ---p 00000000 00:00 0
ffffab410000-ffffab610000 rw-p 00000000 00:00 0
ffffab800000-ffffab810000 ---p 00000000 00:00 0
ffffab810000-ffffaba10000 rw-p 00000000 00:00 0
ffffabc00000-ffffabc10000 ---p 00000000 00:00 0
ffffabc10000-ffffabe10000 rw-p 00000000 00:00 0
ffffac000000-ffffac5e5000 rw-p 00000000 00:00 0
ffffac5e5000-ffffb0000000 ---p 00000000 00:00 0
ffffb0400000-ffffb0410000 ---p 00000000 00:00 0
ffffb0410000-ffffb0610000 rw-p 00000000 00:00 0
ffffb0800000-ffffb0810000 ---p 00000000 00:00 0
ffffb0810000-ffffb0a10000 rw-p 00000000 00:00 0
ffffb0a5b000-ffffb0c00000 r--s 00000000 00:3e 3227735 /usr/lib/aarch64-linux-gnu/libc.so.6
ffffb0c00000-ffffb0c10000 ---p 00000000 00:00 0
ffffb0c10000-ffffb0e10000 rw-p 00000000 00:00 0
ffffb0e1a000-ffffb0fbf000 r--p 00000000 00:3e 3227735 /usr/lib/aarch64-linux-gnu/libc.so.6
ffffb0fbf000-ffffb0fc0000 ---p 00000000 00:00 0
ffffb0fc0000-ffffb1000000 rw-p 00000000 00:00 0
ffffb1000000-ffffb1010000 ---p 00000000 00:00 0
ffffb1010000-ffffb1210000 rw-p 00000000 00:00 0
ffffb1230000-ffffb1247000 r-xp 00000000 00:3e 2391403 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/enc/trans/single_byte.so
ffffb1247000-ffffb125b000 ---p 00017000 00:3e 2391403 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/enc/trans/single_byte.so
ffffb125b000-ffffb1260000 r--p 0001b000 00:3e 2391403 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/enc/trans/single_byte.so
ffffb1260000-ffffb1261000 rw-p 00020000 00:3e 2391403 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/enc/trans/single_byte.so
ffffb1270000-ffffb1278000 r-xp 00000000 00:3e 2391446 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/stringio.so
ffffb1278000-ffffb128f000 ---p 00008000 00:3e 2391446 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/stringio.so
ffffb128f000-ffffb1290000 r--p 0000f000 00:3e 2391446 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/stringio.so
ffffb1290000-ffffb1291000 rw-p 00010000 00:3e 2391446 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/stringio.so
ffffb12a0000-ffffb12b0000 rw-p 00000000 00:00 0
ffffb12b0000-ffffb12ba000 r-xp 00000000 00:3e 2400437 /var/lib/gems/3.2.0/gems/json-2.12.2/lib/json/ext/generator.so
ffffb12ba000-ffffb12cf000 ---p 0000a000 00:3e 2400437 /var/lib/gems/3.2.0/gems/json-2.12.2/lib/json/ext/generator.so
ffffb12cf000-ffffb12d0000 r--p 0000f000 00:3e 2400437 /var/lib/gems/3.2.0/gems/json-2.12.2/lib/json/ext/generator.so
ffffb12d0000-ffffb12d1000 rw-p 00010000 00:3e 2400437 /var/lib/gems/3.2.0/gems/json-2.12.2/lib/json/ext/generator.so
ffffb12e0000-ffffb12e6000 r-xp 00000000 00:3e 2400447 /var/lib/gems/3.2.0/gems/json-2.12.2/lib/json/ext/parser.so
ffffb12e6000-ffffb12ff000 ---p 00006000 00:3e 2400447 /var/lib/gems/3.2.0/gems/json-2.12.2/lib/json/ext/parser.so
ffffb12ff000-ffffb1300000 r--p 0000f000 00:3e 2400447 /var/lib/gems/3.2.0/gems/json-2.12.2/lib/json/ext/parser.so
ffffb1300000-ffffb1301000 rw-p 00010000 00:3e 2400447 /var/lib/gems/3.2.0/gems/json-2.12.2/lib/json/ext/parser.so
ffffb1310000-ffffb1316000 r-xp 00000000 00:3e 2391420 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/etc.so
ffffb1316000-ffffb132f000 ---p 00006000 00:3e 2391420 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/etc.so
ffffb132f000-ffffb1330000 r--p 0000f000 00:3e 2391420 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/etc.so
ffffb1330000-ffffb1331000 rw-p 00010000 00:3e 2391420 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/etc.so
ffffb1340000-ffffb1400000 rw-p 00000000 00:00 0
ffffb1400000-ffffb2699000 r-xp 00000000 00:2b 6393 /wasmtime-rb/lib/wasmtime/wasmtime_rb.so
ffffb2699000-ffffb26af000 ---p 01299000 00:2b 6393 /wasmtime-rb/lib/wasmtime/wasmtime_rb.so
ffffb26af000-ffffb2740000 r--p 0129f000 00:2b 6393 /wasmtime-rb/lib/wasmtime/wasmtime_rb.so
ffffb2740000-ffffb2745000 rw-p 01330000 00:2b 6393 /wasmtime-rb/lib/wasmtime/wasmtime_rb.so
ffffb2745000-ffffb2746000 rw-p 00000000 00:00 0
ffffb2760000-ffffb2840000 rw-p 00000000 00:00 0
ffffb2840000-ffffb2848000 r-xp 00000000 00:3e 3227757 /usr/lib/aarch64-linux-gnu/libffi.so.8.1.4
ffffb2848000-ffffb285f000 ---p 00008000 00:3e 3227757 /usr/lib/aarch64-linux-gnu/libffi.so.8.1.4
ffffb285f000-ffffb2860000 r--p 0000f000 00:3e 3227757 /usr/lib/aarch64-linux-gnu/libffi.so.8.1.4
ffffb2860000-ffffb2861000 rw-p 00010000 00:3e 3227757 /usr/lib/aarch64-linux-gnu/libffi.so.8.1.4
ffffb2870000-ffffb287d000 r-xp 00000000 00:3e 2400452 /var/lib/gems/3.2.0/gems/fiddle-1.1.8/lib/fiddle.so
ffffb287d000-ffffb288f000 ---p 0000d000 00:3e 2400452 /var/lib/gems/3.2.0/gems/fiddle-1.1.8/lib/fiddle.so
ffffb288f000-ffffb2890000 r--p 0000f000 00:3e 2400452 /var/lib/gems/3.2.0/gems/fiddle-1.1.8/lib/fiddle.so
ffffb2890000-ffffb2891000 rw-p 00010000 00:3e 2400452 /var/lib/gems/3.2.0/gems/fiddle-1.1.8/lib/fiddle.so
ffffb28a0000-ffffb28bf000 r-xp 00000000 00:3e 3227760 /usr/lib/aarch64-linux-gnu/libgcc_s.so.1
ffffb28bf000-ffffb28cf000 ---p 0001f000 00:3e 3227760 /usr/lib/aarch64-linux-gnu/libgcc_s.so.1
ffffb28cf000-ffffb28d0000 r--p 0001f000 00:3e 3227760 /usr/lib/aarch64-linux-gnu/libgcc_s.so.1
ffffb28d0000-ffffb28d1000 rw-p 00020000 00:3e 3227760 /usr/lib/aarch64-linux-gnu/libgcc_s.so.1
ffffb28e0000-ffffb28e2000 r-xp 00000000 00:3e 2391419 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/erb/escape.so
ffffb28e2000-ffffb28ff000 ---p 00002000 00:3e 2391419 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/erb/escape.so
ffffb28ff000-ffffb2900000 r--p 0000f000 00:3e 2391419 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/erb/escape.so
ffffb2900000-ffffb2901000 rw-p 00010000 00:3e 2391419 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/erb/escape.so
ffffb2910000-ffffb2916000 r-xp 00000000 00:3e 2391447 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/strscan.so
ffffb2916000-ffffb292f000 ---p 00006000 00:3e 2391447 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/strscan.so
ffffb292f000-ffffb2930000 r--p 0000f000 00:3e 2391447 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/strscan.so
ffffb2930000-ffffb2931000 rw-p 00010000 00:3e 2391447 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/strscan.so
ffffb293f000-ffffb2a00000 rw-p 00000000 00:00 0
ffffb2a00000-ffffb2a01000 ---p 00000000 00:00 0
ffffb2a01000-ffffb2aa2000 rw-p 00000000 00:00 0
ffffb2aa2000-ffffb2aa3000 ---p 00000000 00:00 0
ffffb2aa3000-ffffb2b44000 rw-p 00000000 00:00 0
ffffb2b44000-ffffb2b45000 ---p 00000000 00:00 0
ffffb2b45000-ffffb2be6000 rw-p 00000000 00:00 0
ffffb2be6000-ffffb2be7000 ---p 00000000 00:00 0
ffffb2be7000-ffffb2c88000 rw-p 00000000 00:00 0
ffffb2c88000-ffffb2c89000 ---p 00000000 00:00 0
ffffb2c89000-ffffb2d2a000 rw-p 00000000 00:00 0
ffffb2d2a000-ffffb2d2b000 ---p 00000000 00:00 0
ffffb2d2b000-ffffb2dcc000 rw-p 00000000 00:00 0
ffffb2dcc000-ffffb2dcd000 ---p 00000000 00:00 0
ffffb2dcd000-ffffb2e6e000 rw-p 00000000 00:00 0
ffffb2e6e000-ffffb2e6f000 ---p 00000000 00:00 0
ffffb2e6f000-ffffb2f10000 rw-p 00000000 00:00 0
ffffb2f10000-ffffb2f11000 ---p 00000000 00:00 0
ffffb2f11000-ffffb2fb2000 rw-p 00000000 00:00 0
ffffb2fb2000-ffffb2fb3000 ---p 00000000 00:00 0
ffffb2fb3000-ffffb3054000 rw-p 00000000 00:00 0
ffffb3054000-ffffb3055000 ---p 00000000 00:00 0
ffffb3055000-ffffb30f6000 rw-p 00000000 00:00 0
ffffb30f6000-ffffb30f7000 ---p 00000000 00:00 0
ffffb30f7000-ffffb3198000 rw-p 00000000 00:00 0
ffffb3198000-ffffb3199000 ---p 00000000 00:00 0
ffffb3199000-ffffb323a000 rw-p 00000000 00:00 0
ffffb323a000-ffffb323b000 ---p 00000000 00:00 0
ffffb323b000-ffffb32dc000 rw-p 00000000 00:00 0
ffffb32dc000-ffffb32dd000 ---p 00000000 00:00 0
ffffb32dd000-ffffb337e000 rw-p 00000000 00:00 0
ffffb337e000-ffffb337f000 ---p 00000000 00:00 0
ffffb337f000-ffffb3420000 rw-p 00000000 00:00 0
ffffb3420000-ffffb3421000 ---p 00000000 00:00 0
ffffb3421000-ffffb34c2000 rw-p 00000000 00:00 0
ffffb34c2000-ffffb34c3000 ---p 00000000 00:00 0
ffffb34c3000-ffffb3564000 rw-p 00000000 00:00 0
ffffb3564000-ffffb3565000 ---p 00000000 00:00 0
ffffb3565000-ffffb3606000 rw-p 00000000 00:00 0
ffffb3606000-ffffb3607000 ---p 00000000 00:00 0
ffffb3607000-ffffb36a8000 rw-p 00000000 00:00 0
ffffb36a8000-ffffb36a9000 ---p 00000000 00:00 0
ffffb36a9000-ffffb374a000 rw-p 00000000 00:00 0
ffffb374a000-ffffb374b000 ---p 00000000 00:00 0
ffffb374b000-ffffb37ec000 rw-p 00000000 00:00 0
ffffb37ec000-ffffb37ed000 ---p 00000000 00:00 0
ffffb37ed000-ffffb388e000 rw-p 00000000 00:00 0
ffffb388e000-ffffb388f000 ---p 00000000 00:00 0
ffffb388f000-ffffb3930000 rw-p 00000000 00:00 0
ffffb3930000-ffffb3931000 ---p 00000000 00:00 0
ffffb3931000-ffffb39d2000 rw-p 00000000 00:00 0
ffffb39d2000-ffffb39d3000 ---p 00000000 00:00 0
ffffb39d3000-ffffb3a74000 rw-p 00000000 00:00 0
ffffb3a74000-ffffb3a75000 ---p 00000000 00:00 0
ffffb3a75000-ffffb3b16000 rw-p 00000000 00:00 0
ffffb3b16000-ffffb3b17000 ---p 00000000 00:00 0
ffffb3b17000-ffffb3bb8000 rw-p 00000000 00:00 0
ffffb3bb8000-ffffb3bb9000 ---p 00000000 00:00 0
ffffb3bb9000-ffffb3c5a000 rw-p 00000000 00:00 0
ffffb3c5a000-ffffb3c5b000 ---p 00000000 00:00 0
ffffb3c5b000-ffffb3cfc000 rw-p 00000000 00:00 0
ffffb3cfc000-ffffb3cfd000 ---p 00000000 00:00 0
ffffb3cfd000-ffffb3d9e000 rw-p 00000000 00:00 0
ffffb3d9e000-ffffb3d9f000 ---p 00000000 00:00 0
ffffb3d9f000-ffffb3e40000 rw-p 00000000 00:00 0
ffffb3e50000-ffffb3e70000 rw-p 00000000 00:00 0
ffffb3e70000-ffffb3e74000 r-xp 00000000 00:3e 2391344 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/cgi/escape.so
ffffb3e74000-ffffb3e8f000 ---p 00004000 00:3e 2391344 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/cgi/escape.so
ffffb3e8f000-ffffb3e90000 r--p 0000f000 00:3e 2391344 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/cgi/escape.so
ffffb3e90000-ffffb3e91000 rw-p 00010000 00:3e 2391344 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/cgi/escape.so
ffffb3ea0000-ffffb6009000 rw-p 00000000 00:00 0
ffffb600f000-ffffb6020000 r--s 00000000 00:3e 2005802 /usr/bin/ruby3.2
ffffb6020000-ffffb6028000 r-xp 00000000 00:3e 2391435 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/pathname.so
ffffb6028000-ffffb603f000 ---p 00008000 00:3e 2391435 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/pathname.so
ffffb603f000-ffffb6040000 r--p 0000f000 00:3e 2391435 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/pathname.so
ffffb6040000-ffffb6041000 rw-p 00010000 00:3e 2391435 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/pathname.so
ffffb6050000-ffffb6052000 r-xp 00000000 00:3e 2391431 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/monitor.so
ffffb6052000-ffffb606f000 ---p 00002000 00:3e 2391431 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/monitor.so
ffffb606f000-ffffb6070000 r--p 0000f000 00:3e 2391431 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/monitor.so
ffffb6070000-ffffb6071000 rw-p 00010000 00:3e 2391431 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/monitor.so
ffffb6080000-ffffb6100000 rw-p 00000000 00:00 0
ffffb6110000-ffffb61d0000 rw-p 00000000 00:00 0
ffffb61d0000-ffffb61d2000 r-xp 00000000 00:3e 2391404 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/enc/trans/transdb.so
ffffb61d2000-ffffb61ef000 ---p 00002000 00:3e 2391404 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/enc/trans/transdb.so
ffffb61ef000-ffffb61f0000 r--p 0000f000 00:3e 2391404 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/enc/trans/transdb.so
ffffb61f0000-ffffb61f1000 rw-p 00010000 00:3e 2391404 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/enc/trans/transdb.so
ffffb6200000-ffffb7200000 rw-p 00000000 00:00 0
ffffb7210000-ffffb7220000 rw-p 00000000 00:00 0
ffffb7220000-ffffb7222000 r-xp 00000000 00:3e 2391360 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/enc/encdb.so
ffffb7222000-ffffb723f000 ---p 00002000 00:3e 2391360 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/enc/encdb.so
ffffb723f000-ffffb7240000 r--p 0000f000 00:3e 2391360 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/enc/encdb.so
ffffb7240000-ffffb7241000 rw-p 00010000 00:3e 2391360 /usr/lib/aarch64-linux-gnu/ruby/3.2.0/enc/encdb.so
ffffb7250000-ffffb7280000 rw-p 00000000 00:00 0
ffffb7290000-ffffb7350000 rw-p 00000000 00:00 0
ffffb735f000-ffffb7460000 rw-p 00000000 00:00 0
ffffb7460000-ffffb75fa000 r-xp 00000000 00:3e 3227735 /usr/lib/aarch64-linux-gnu/libc.so.6
ffffb75fa000-ffffb760d000 ---p 0019a000 00:3e 3227735 /usr/lib/aarch64-linux-gnu/libc.so.6
ffffb760d000-ffffb7610000 r--p 0019d000 00:3e 3227735 /usr/lib/aarch64-linux-gnu/libc.so.6
ffffb7610000-ffffb7612000 rw-p 001a0000 00:3e 3227735 /usr/lib/aarch64-linux-gnu/libc.so.6
ffffb7612000-ffffb761e000 rw-p 00000000 00:00 0
ffffb7620000-ffffb76a5000 r-xp 00000000 00:3e 3227777 /usr/lib/aarch64-linux-gnu/libm.so.6
ffffb76a5000-ffffb76bf000 ---p 00085000 00:3e 3227777 /usr/lib/aarch64-linux-gnu/libm.so.6
ffffb76bf000-ffffb76c0000 r--p 0008f000 00:3e 3227777 /usr/lib/aarch64-linux-gnu/libm.so.6
ffffb76c0000-ffffb76c1000 rw-p 00090000 00:3e 3227777 /usr/lib/aarch64-linux-gnu/libm.so.6
ffffb76d0000-ffffb76fd000 r-xp 00000000 00:3e 3227744 /usr/lib/aarch64-linux-gnu/libcrypt.so.1.1.0
ffffb76fd000-ffffb770f000 ---p 0002d000 00:3e 3227744 /usr/lib/aarch64-linux-gnu/libcrypt.so.1.1.0
ffffb770f000-ffffb7710000 r--p 0002f000 00:3e 3227744 /usr/lib/aarch64-linux-gnu/libcrypt.so.1.1.0
ffffb7710000-ffffb7711000 rw-p 00030000 00:3e 3227744 /usr/lib/aarch64-linux-gnu/libcrypt.so.1.1.0
ffffb7711000-ffffb7719000 rw-p 00000000 00:00 0
ffffb7720000-ffffb779a000 r-xp 00000000 00:3e 3227764 /usr/lib/aarch64-linux-gnu/libgmp.so.10.5.0
ffffb779a000-ffffb77af000 ---p 0007a000 00:3e 3227764 /usr/lib/aarch64-linux-gnu/libgmp.so.10.5.0
ffffb77af000-ffffb77b0000 r--p 0007f000 00:3e 3227764 /usr/lib/aarch64-linux-gnu/libgmp.so.10.5.0
ffffb77b0000-ffffb77b1000 rw-p 00080000 00:3e 3227764 /usr/lib/aarch64-linux-gnu/libgmp.so.10.5.0
ffffb77c0000-ffffb77da000 r-xp 00000000 00:3e 3227848 /usr/lib/aarch64-linux-gnu/libz.so.1.3
ffffb77da000-ffffb77ef000 ---p 0001a000 00:3e 3227848 /usr/lib/aarch64-linux-gnu/libz.so.1.3
ffffb77ef000-ffffb77f0000 r--p 0001f000 00:3e 3227848 /usr/lib/aarch64-linux-gnu/libz.so.1.3
ffffb77f0000-ffffb77f1000 rw-p 00020000 00:3e 3227848 /usr/lib/aarch64-linux-gnu/libz.so.1.3
ffffb7800000-ffffb7bb4000 r-xp 00000000 00:3e 1858834 /usr/lib/aarch64-linux-gnu/libruby-3.2.so.3.2.3
ffffb7bb4000-ffffb7bc6000 ---p 003b4000 00:3e 1858834 /usr/lib/aarch64-linux-gnu/libruby-3.2.so.3.2.3
ffffb7bc6000-ffffb7bd0000 r--p 003b6000 00:3e 1858834 /usr/lib/aarch64-linux-gnu/libruby-3.2.so.3.2.3
ffffb7bd0000-ffffb7bd1000 rw-p 003c0000 00:3e 1858834 /usr/lib/aarch64-linux-gnu/libruby-3.2.so.3.2.3
ffffb7bd1000-ffffb7be3000 rw-p 00000000 00:00 0
ffffb7be5000-ffffb7bf6000 r--p 00000000 00:3e 2005802 /usr/bin/ruby3.2
ffffb7bf6000-ffffb7c1d000 r-xp 00000000 00:3e 3227715 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1
ffffb7c27000-ffffb7c2b000 rw-p 00000000 00:00 0
ffffb7c2e000-ffffb7c2f000 r-xp 00000000 00:29 6394 /run/host_virtiofs/Users/wsta/repos/wasmtime-rb/jit-7579.dump
ffffb7c2f000-ffffb7c31000 rw-p 00000000 00:00 0
ffffb7c31000-ffffb7c33000 r--p 00000000 00:00 0 [vvar]
ffffb7c33000-ffffb7c34000 r-xp 00000000 00:00 0 [vdso]
ffffb7c34000-ffffb7c36000 r--p 0002e000 00:3e 3227715 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1
ffffb7c36000-ffffb7c38000 rw-p 00030000 00:3e 3227715 /usr/lib/aarch64-linux-gnu/ld-linux-aarch64.so.1
ffffea9b8000-ffffeb1b7000 rw-p 00000000 00:00 0 [stack]

Aborted
/usr/bin/ruby3.2 -I/var/lib/gems/3.2.0/gems/rspec-core-3.13.4/lib:/var/lib/gems/3.2.0/gems/rspec-support-3.13.4/lib /var/lib/gems/3.2.0/gems/rspec-core-3.13.4/exe/rspec --pattern spec/**{,/*/**}/*_spec.rb failed

@william-stacken william-stacken force-pushed the preopened-dir branch 2 times, most recently from 815d83b to 3fbaf8b Compare September 5, 2025 07:46
@william-stacken
Copy link
Contributor Author

Alright, it appears to solve the problem if the array is allocated before the borrow.

@saulecabrera
Copy link
Member

I'll take a look at this today!

@saulecabrera saulecabrera self-requested a review September 5, 2025 11:23
mapped_directory.push(dir_perms).unwrap();
mapped_directory.push(file_perms).unwrap();

let init_directory = RArray::new();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the creation of this RArray be moved under the if on line 267? Else we'd be creating an array even though it won't be needed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we consider storing these in a Vec<SomeStruct> instead of nested RArrays?

Pros:

  • Sidesteps the refcell+alloc issue altogether (the top-level RArray is gone).
  • Fewer Ruby allocations: no need to alloc an Array to store the arguments for each call.
  • Errors converting Ruby args into WasiCtxBuilder.preopened_dir-compatible args will show up immediately, not delayed in a future call. Tiny detail, but makes errors easier to debug.

Cons:

  • Requires implementing such struct to hold the arguments, and marking the string it contains.
  • Something else I'm not seeing?

I didn't mean to hijack the PR, feel free to ignore if not useful.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the suggestion is reasonable, personally the main advantage that I see, is not having to incur in the overhead of creating a Ruby array each time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I switched to using a Vec and there are still no garbage collection problems.

Comment on lines 311 to 324
let host_path = host_path.to_string().unwrap();
let guest_path = guest_path.to_string().unwrap();
let dir_perms: DirPerms = PermsSymbolEnum(dir_perms).try_into()?;
let file_perms: FilePerms = PermsSymbolEnum(file_perms).try_into()?;

let mapped_dir = MappedDirectory {
host_path,
guest_path,
dir_perms,
file_perms,
};

let mut inner = rb_self.inner.borrow_mut();
inner.mapped_directories.push(mapped_dir);
Copy link
Member

@saulecabrera saulecabrera Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To:

  • Keep things consistent with the other build options (see e.g., env), could we make MappedDirectory hold the Ruby values rather than eagerly converting them to Rust on each call?
  • Related to point 1, that approach will also result in less overhead in case any of the other values fails to validate and centralizing everything in the build call.

Copy link
Member

@saulecabrera saulecabrera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@saulecabrera saulecabrera merged commit 5f4de3f into bytecodealliance:main Sep 9, 2025
11 checks passed
@jbourassa
Copy link
Collaborator

Great work William, thank you for pushing this over the finish line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Map directory for instance
4 participants